/// 表单验证工具类
class FormValidator {
  /// 验证必填字段
  static String? validateRequired(String? value, String fieldName) {
    if (value == null || value.isEmpty) {
      return 'Please enter $fieldName';
    }
    return null;
  }

  /// 验证数字字段
  static String? validateNumber(String? value, String fieldName) {
    if (value == null || value.isEmpty) {
      return 'Please enter $fieldName';
    }
    if (double.tryParse(value) == null) {
      return 'Please enter a valid number';
    }
    if (double.parse(value) <= 0) {
      return 'Please enter a number greater than 0';
    }
    return null;
  }

  /// 验证图片上传
  static String? validateImages(List? images) {
    if (images == null || images.isEmpty) {
      return 'Please upload at least one image';
    }
    return null;
  }

  /// 验证子类别选择
  static String? validateSubcategory(String? value) {
    if (value == null || value.isEmpty) {
      return 'Please select a subcategory';
    }
    return null;
  }
}